<template>
  <div id="radio_group" class="radiogroup">
    <div class="title" v-if="title">{{ title }}</div>
    <div class="radio_wrap">
      <div
        :class="{ radio_item: true, radio_item_blue: radio_value == item.title }"
        v-for="(item, index) in radio_values"
        :key="'radio_group' + index"
        @click="
          now_radio_value = item.title;
          $emit('returnBack', now_radio_value);
        "
        class="myBox"
      >
        {{ item.title }}
        <el-tooltip
          class="item"
          effect="light"
          placement="bottom"
          popper-class="mytooltip"
        >
          <div
            slot="content"
            v-for="(item1, index1) in item.tipWords"
            :key="'ra' + index1"
          >
            <p>
              {{ item1 }}
            </p>
          </div>
          <div
            class="whatTipBox"
            :class="{ activeBg: radio_value == item.title }"
          ></div>
        </el-tooltip>
      </div>
    </div>
  </div>
</template>

<script>
export default {
  name: "radio_group",
  data() {
    return {
      now_radio_value: this.radio_value,
    };
  },
  model: {
    prop: "radio_value",
    event: "returnBack",
  },
  props: ["radio_values", "radio_value", "title"],
  created: function () {
    this.$watch("radio_value", function (newValue, oldValue) {
      this.now_radio_value = this.radio_value;
    });
  },
};
</script>
<style scoped lang="less">
#radio_group {
  display: flex;
  .title {
    font-size: 14px;
    line-height: 32px;
    white-space: nowrap;
    color: #888888;
    margin-right: 20px;
  }
  .radio_item {
    cursor: pointer;
    outline: none;
    height: 32px;
    border-radius: 4px;
    font-size: 14px;
    color: #555555;
    line-height: 32px;
    margin-bottom: 10px;
    padding: 0 16px;
    margin-left: 8px;
    box-sizing: border-box;
  }
  .radio_item_blue {
    color: #fff !important;

    background-color: #1779ff !important;
  }
  .radio_item:first-child {
    margin-left: 0;
  }
  .radio_wrap {
    display: flex;
    flex-wrap: wrap;
    .myBox {
      display: flex;
      justify-content: center;
      align-items: center;
      img {
        display: inline-block;
        width: 16px;
        height: 16px;
        margin-top: -3px;
        margin-left: 3px;
      }
      .whatTipBox {
        display: inline-block;
        width: 14px;
        height: 14px;
        margin-left: 6px;
        border-radius: 50%;
        background-image: url("../assets/meng/search_result04.png");
        background-repeat: no-repeat;
        background-size: 100% 100%;
      }
      .activeBg {
        background-image: url("../assets/wang/goods/what01.png") !important;
      }
    }
  }
}
</style>
